package com.example.leetdemo.process;

import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class Solution396 {

    public static int maxRotateFunction(int[] nums) {
        int[] result = new int[nums.length];
        int[] nums2 = new int[nums.length * 2];
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            nums2[i] = nums[i];
            count += nums[i];
            result[0] += i * nums[i];
        }
        for (int i = 0; i < nums.length; i++) {
            nums2[i + nums.length] = nums[i];
        }
        for (int i = 1; i < nums.length; i++) {
            result[i] = result[i - 1] + count - nums.length * nums2[nums.length - i];
        }
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(max, result[i]);
        }
        return max;
    }

    public static void main(String[] args) {
//        System.err.println(maxRotateFunction(new int[] {
//                4,3,2,6
//        }));

        List<Integer> list = new ArrayList<>();
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.forEach(System.err::println);

        Short a = (short) 101;

        System.err.println(a == (short) 101);

        JSONObject j = new JSONObject();
        j.put("list", new int[] {1,2,3,4,5});
        List<Integer> ints = j.getJSONArray("list").toJavaList(Integer.class);
        j.put("companyCode", 12345L);
        System.err.println(j.containsKey("companyCode"));
        System.err.println("".equals(j.get("companyCode")));

    }

}
